package com.etennis.utils;

import java.util.Random;
import java.util.UUID;

public class RandomUtil {
    /**
     * 生成兑换码
     * @return
     */
    public static String generateCode(){
        UUID uuid = UUID.randomUUID();
        String pre = uuid.toString().replace("-", "").substring(0, 5);
        StringBuilder sb=new StringBuilder();
        for (int i = 0; i < 5; i++) {
            sb.append(pre.charAt(i)>='a'&&pre.charAt(i)<='z'?(char)(pre.charAt(i)+'A'-'a'):pre.charAt(i));
        }
        return sb.toString();
    }

    /**
     * 生成账号
     * @return
     */
    public static String generateAccount(){
        Random random = new Random();
        StringBuilder account = new StringBuilder();
        for (int i = 0; i < 11; i++) {
            account.append(random.nextInt(10)); // 生成0到9之间的随机数字
        }
        return account.toString();
    }

}
